package htmlEamilTest.htmlEamilTest;

import org.junit.Test;

import htmlEamilTest.htmlEamilTest.util.MailUtil;

public class SendMail {

	@Test
    public void sendMail(){
        Mail mail = new Mail();
        // 设置邮件服务器 
        mail.setHost("smtp.qq.com");
        // 发件人邮件地址
        mail.setSender("1501520837@qq.com");
        // 发件人名称
        //https://blog.csdn.net/qq_41251714/article/details/89254908?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase
        mail.setName("htmlEamil-发送HTML代码-何胜金");
        // 登录账号,一般都是和邮箱名一样吧  
        mail.setUsername("1501520837@qq.com");
        // 发件人邮箱的登录密码  
        mail.setPassword("vcschrbgnafxgcbc");
        // 接收人  
        mail.setReceiver("2356899074@qq.com");
        mail.setReceiverName("我要测试");
        mail.setSubject("htmlEamil-发送HTML代码-何胜金");
        String html = "<!DOCTYPE html>";
        html += "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
        html += "<title>Insert title here</title>";
        html += "</head><body>";
        html += "<div style=\"width:600px;height:400px;margin:50px auto;\">";
        html += "<h1>我来看看邮件是否发送成功呢</h1><br/><br/>";
        html += "<p>下面是通过该协议可以创建一个指向电子邮件地址的超级链接，通过该链接可以在Internet中发送电子邮件</p><br/>";
        html += "<a href=\"www.baidu.com\">send mail</a>";
        html += "</div>";
        html += "</body></html>";
        mail.setMessage(html);
        
        new MailUtil().send(mail);
    }
	
}
